//
//  YLLTabBarViewController.swift
//  YLLSina
//
//  Created by 于玲玲 on 16/7/28.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class YLLTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewController()
        
        let ylltabBar = YLLTabBar()
        
        ylltabBar.tintColor = UIColor.orangeColor()
        
        setValue(ylltabBar, forKey: "tabBar")
        
        
        ylltabBar.closure = {
            printLog("回调成功，实现页面跳转")
        }
       
    }

    
    
    
    
    func addChildViewController() {
        
        addChildViewController(YLLHomeViewController(), imageName: "tabbar_home", titleName: "首页")
        
        addChildViewController(YLLMessageViewController(), imageName: "tabbar_message_center", titleName:"消息")
        addChildViewController(YLLFindViewController(), imageName: "tabbar_discover", titleName:"发现")
        addChildViewController(YLLSettingViewController(), imageName: "tabbar_profile", titleName:"我")
        
    }
    
    
    
    
    
    
    
    
    
    
    
    func addChildViewController(childController: UIViewController,imageName: String,titleName: String) {
        
     childController.tabBarItem.image = UIImage(named: imageName)
        
        childController.tabBarItem.selectedImage = UIImage(named: "\(imageName)_highlighted")
        
        tabBar.tintColor = UIColor.orangeColor()
        
        childController.title = titleName
        
        let nav = UINavigationController(rootViewController: childController)
        
        addChildViewController(nav)
        
    }
    
    
    
    
    
    
    
    
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    


}
